from models import db
from datetime import datetime
from sqlalchemy import DECIMAL

class ScoreWeight(db.Model):
    __tablename__ = 'score_weights'
    
    weight_id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    company_id = db.Column(db.Integer, db.ForeignKey('companies.company_id'), nullable=False, unique=True)
    technical_weight = db.Column(DECIMAL(5,2), nullable=False, default=0.40)
    learning_weight = db.Column(DECIMAL(5,2), nullable=False, default=0.20)
    team_weight = db.Column(DECIMAL(5,2), nullable=False, default=0.15)
    problem_solving_weight = db.Column(DECIMAL(5,2), nullable=False, default=0.15)
    communication_weight = db.Column(DECIMAL(5,2), nullable=False, default=0.10)
    created_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
    updated_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)

    # 关联到Company模型
    company = db.relationship('Company', backref=db.backref('score_weight', uselist=False)) 